package com.leyantech.ecp.agenx.task.filter.task;

import com.leyantech.ecp.agenx.task.filter.AssistantOnlineFilter;

import com.google.inject.Singleton;
import io.vertx.core.json.JsonObject;
import lombok.extern.slf4j.Slf4j;

/**
 * @author eahau, {@literal <eahau@foxmail.com>}
 * @date 2022-11-15.
 * @see com.leyantech.ecp.agenx.task.message.PddJobKfkMsg
 */
@Slf4j
@Singleton
public class TaskMessageFilter extends AssistantOnlineFilter<JsonObject> {

  @Override
  protected String getStoreId(JsonObject pddJobKfkMsg) {
    return pddJobKfkMsg.getString("sid");
  }

  @Override
  protected String getAssistantId(JsonObject pddJobKfkMsg) {
    return pddJobKfkMsg.getString("aid", "");
  }

  @Override
  protected Object logMessage(JsonObject pddJobKfkMsg) {
    return new Object() {
      @Override
      public String toString() {
        return new JsonObject()
            .put("orderId", pddJobKfkMsg.getString("orderId"))
            .put("buyerId", pddJobKfkMsg.getString("buyerId"))
            .toString();
      }
    };
  }

}
